package ChatSystem;

import java.io.IOException;
import java.net.InetAddress;

import chatsystemTDa2.Message;


public interface RemoteChatSystem {
	/**
	 * Acknowledge the Hello message of the remote user
	 * @param user The remote user to notify
	 */
	public abstract void sendHelloAck(User user);

	/**
	 * Broadcasts our connection attempt and starts the network messages handling thread.
	 * @throws IOException When the network messages handling thread could not establish a connection.
	 */
	public abstract void sendHello() throws IOException;


	/**
	 * Broadcasts our disconnection of the ChatSystem and stops the network messages handling thread.
	 */
	public abstract void sendGoodbye();
	
	/**
	 * Starts the TCP transfer thread which will notify the remote user of the file approval
	 * @param message The message encapsulating the file to be downloaded
	 */
	public abstract void acceptFileRequest(ChatMessage.ChatFileMessage message);
	
	/**
	 * Notifies the remote user that we just denied his file transfer request.
	 * @param message The message encapsulating the file to be discarded.
	 */
	public abstract void declineFileRequest(ChatMessage.ChatFileMessage message);
	
	/**
	 * Forwards the message to send to the message sender.
	 * @param message The message to send
	 */
	public abstract void sendMessage(ChatMessage.ChatTextMessage message);
	
	/**
	 * Notifies the remote ChatSystem that we wish to share a file with him and forward the file to the file sender
	 * @param message The message encapsulating the file
	 */
	public abstract void sendFileRequest(ChatMessage.ChatFileMessage message);
	
	/**
	 * Manages the handling of the different kind of messages received on the network.
	 * @param message The generic message to be discriminated
	 * @param address The sender Internet address
	 */
	public abstract void onMessageReceived(Message message, InetAddress address);}
